<template>
  <div>
    我是分类子组件
    <button @click="emitFn">子传父</button>
  </div>
</template>

<script setup lang='ts'>
import { defineEmits } from 'vue'
// 实现子传父
import { ref, reactive } from 'vue'
const userobj = ref({
  username: '付豪',
  age: 20
})

// const emit = defineEmits(['myevent'])

// 设置ts类型
interface userprops {
  username: string
  age: number
}
const emit = defineEmits<{
  (e: 'myevent', userobj: userprops): void
}>()
const emitFn = () => {
  // 子传父
  emit('myevent', userobj.value)
}
</script>
<style scoped></style>